package com.junzhiit.nengji.api.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.api.service.QuestionService;
import com.junzhiit.nengji.api.web.vo.QuestionUseVO;
import com.junzhiit.nengji.api.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {
	
	@Autowired
	private QuestionService questionService;
	
	@ApiOperation(value = "查询所有的问题")
	@RequestMapping(method = RequestMethod.GET)
	public ResultVO findAll() {
		return questionService.findAll();
	}
	
	@ApiOperation(value = "查询问题")
	@RequestMapping(value = "/info", method = RequestMethod.GET)
	public ResultVO findQuestion(QuestionUseVO questionUseVO) {
		AssertUtil.notBlank(questionUseVO.getQuestionId(), "questionId is required.");
		AssertUtil.notBlank(questionUseVO.getUserId(), "userId is required");
		return questionService.findQuestion(questionUseVO);
	}

	@ApiOperation(value = "顶或踩")
	@RequestMapping(method = RequestMethod.PUT)
	public ResultVO edit(QuestionUseVO questionUseVO) {
		AssertUtil.notBlank(questionUseVO.getQuestionId(), "questionId is required.");
		AssertUtil.notBlank(questionUseVO.getUserId(), "userId is required");
		AssertUtil.notNull(questionUseVO.getStatus(), "status is required");
		return questionService.edit(questionUseVO);
	}
}
